The enclosed ResEdit file contains MacsBug macros which can help you recover from system crashes safely. I gathered these commands from various places over the period of about a year and have since incorporated them into my regular “crash routine”. As a regular user of the student computer labs at the University of Illinois at Chicago, I see Macs crash all the time (Netscape Navigator loves to do this). I’ve found that using these macros after a crash (instead of simply pushing the restart button on the programmer’s switch) can often reduce the amount of corruption your hard drive suffers and decrease the amount of time your Mac takes to restart after a crash. This method works by allowing your Mac system to run standard cleanup routines (flushing disk buffers, closing files, unmounting disks, etc.) — if at all possible — before restarting the machine. In less severe cases, the crashed program can itself be restarted or aborted so you can save your work in other open programs before restarting. (I know System 7 has a “force quit” feature. I never use it. The methods used here are more reliable.)
These macros belong in the public domain.
Installing the macros
These macros require MacsBug 6.5.3. Because they are assigned to the function keys on an extended keyboard, they will not work with an earlier version without modification. (If you do not have an extended keyboard, see the usage section of this file for a workaround.) The macros have not been tested with any version of MacsBug other than 6.5.3, so you’ll have to experiment before using them with another version. It would be a good idea to save your files and quit all running programs before experimenting, as any unsaved information is likely to be lost just as it would be in a real crash.
MacsBug is freely available for download from Apple’s Software Update Library at http://www.info.apple.com/. Just search for “macsbug”. Once you have MacsBug, follow these steps to install the crash recovery macros:
1. Find the file named “MacsBug” in its distribution package. It should be inside a folder called “Put into System folder”. Drag MacsBug into your system folder. Leave it where the system puts it; it does not need to be in a subfolder.
2. Create a folder and name it “MacsBug Preferences”. Into this new folder drag the KCHR resource file from the folder called “Put into Debugger Prefs file”. For the U.S. version of MacsBug, this file is called “KCHR (U.S.)”.
3. If you have a Power Macintosh, you will also want to drag into your MacsBug Preferences folder the file named “PowerPC dcmds”, which you will find inside the “into MacsBug Preferences folder” inside “Put into Preferences folder”.
4. Now drag the “MacsBug crash macros rev 1a” file into your MacsBug Preferences folder.
5. Drag the MacsBug Preferences folder into your system folder. Leave it at the root level of the system folder.
6. Restart your Macintosh. When you see the message “Debugger installed.” under the usual “Welcome to Macintosh.”, MacsBug and the crash recovery macros have been successfully loaded.
Using the macros
When your Mac crashes, most of the time it will fall directly into MacsBug with the name of the system error near the bottom of its window. (While MacsBug is installed, you will no longer receive standard useless bomb dialogs.) If you know that your Mac has crashed or frozen but MacsBug doesn’t appear, it can be activated by the interrupt button on the programmer’s switch.
The programmer’s switch consists of two small buttons on one side of the Macintosh case. The reset button is marked with a triangle and the interrupt button is marked with a checkmark or circle. The location of the programmer’s switch depends on the model; on some it is on one of the sides and on others it is on the front or back. Your manual should tell you where to find the programmer’s switch if you have one or how to install it if it doesn’t come pre-installed. Some models don’t even have physical switches and instead use the Control-Command()-Powerkey(<) combination to cause a restart and the Command()-Powerkey(<) combination to cause an interrupt. If your model doesn’t have a physical switch and the interrupt keypress doesn’t work, you’re simply out of luck. You’ll either have to use the macros if the system falls into MacsBug or use the restart keypress to bail out otherwise.
Once you are in MacsBug, proceed to recover from the crash by pressing the function keys in order starting with F1 and continuing through F9. This will execute the macros in order of severity. Please be aware that these macros will not in all cases be able to return you to a normal screen or restart your Mac. If any macro fails, continue to the next one, reactivating MacsBug with the interrupt button if necessary. If your Mac simply crashes again and MacsBug won’t appear or refuses to function, press the restart button on the programmer’s switch. Turn off the power to your Mac only as a last resort.
If you don’t have an extended keyboard with function keys, you can run each macro by typing “DoF” and the number of a function key. For example, to run the macro assigned to F2, type “DoF2” and press Return.
Even if your Mac can be returned to a useful state after a crash without restarting, I would still suggest restarting as soon as possible. After a crash, your system will often be unstable and likely to crash again. After restarting, use Apple’s Disk First Aid to verify your hard disks and any floppies that were present on the desktop to determine if any damage was done by the crash, and repair it. You should do this after every crash. Just to be careful (read “paranoid”), I always scan my System file with MicroMat’s TechTool after every crash to make sure it hasn’t been damaged. This can happen; my System file has been damaged several times by severe (read “Microsoft”) crashes. If you own a more powerful repair utility such as Symantec’s Norton Utilities, I recommend running it once a week to clean up anything Disk First Aid may have missed.
About the macros
(Commands in boldface can also be used with the MACS debugger in the Macintosh ROM, which is always available using the programmer’s switch interrupt button even when MacsBug is not installed. The three commands beginning with “SM” comprise a viable crash recovery method on their own. A semi-colon (;) represents a press of the Return key. Ignore anything after a crosshatch (#) — these are comments and not part of the commands.)
Macro table
Name Expansion
DoF1 EA # re-init current application
DoF1 attempts to quit and immediately restart the crashed program by using MacsBug’s internal routine. This macro has the effect of using System 7’s Command()-Option-Escape key sequence to quit the program and then double-clicking its icon. Sometimes this is exactly what you want to do. Of course, all unsaved work is lost.
DoF2 SM 0 A9 F4;G 0 # force quit
DoF2 attempts to quit the crashed program by executing a standard “quit application” command in 68000 assembler. This method works more reliably than System 7’s Command()-Option-Escape key sequence.
This macro and the two others in boldface (excluding “G”) tend not to work on a PowerMac if the crashed program was running PowerPC code — instead they will most likely cause an illegal instruction error. The easiest way to tell whether your machine was running PowerPC code is to type ‘TD’ and note whether MacsBug reports “680x0 Registers” or “PowerPC 60xx Registers”. If PowerPC code was running, use F3 or F5 instead of F2 or F4, respectively.
DoF3 ES # exit to shell
DoF3 attempts to quit the crashed program by using MacsBug’s internal abort routine. Unlike DoF2, this macro also works in PowerPC mode. However, I have found that it works slightly less often than DoF2.
DoF4 SM 0 3F 3C 00 02 A8 95;G 0 # safe restart
DoF4 attempts to restart the Macintosh by executing a 68000 assembler call to the Shutdown Manager. Any shutdown routines patched into the Shutdown Manager will also execute (that includes Norton FileSaver and General Controls 7.5.1 Shut Down Warning, among others).
DoF5 RS # restart
DoF5 attempts to restart the Macintosh by using MacsBug’s internal restart routine. Unlike DoF4, this macro also works in PowerPC mode. The MacsBug command doesn’t run all installed shutdown routines before restarting, so it’s not quite as safe as DoF4.
DoF6 RB # reboot without unmounting secondary drives
DoF6 attempts to restart the Macintosh by using MacsBug’s internal reboot routine. This macro is identical to DoF5, except this MacsBug command unmounts only the startup volume before rebooting, leaving other mounted volumes vulnerable to corruption.
DoF7 SM 0 3F 3C 00 01 A8 95;G 0 # safe shut down
DoF7 attempts to shut down the Macintosh by executing a 68000 assembler call to the Shutdown Manager. Use this macro instead of DoF4 if you just want to shut down your crashing Mac (as when all this crashing is driving you nuts and you don’t want to wait for the Mac to restart again!). In general, sometimes this shutdown macro will work when the restart macros won’t.
DoF8 printf "Press Control-Apple-Powerkey to restart."
DoF8 prints you a reminder that the preceding macros are not working and it’s time to hard-restart your machine by using Control-Command(/)-Powerkey(<) or the restart button of the programmer’s switch. At this point, it’s obvious that the computer is not responding to normal commands.
DoF9 printf "Find the small, flat power switch on the back panel? Push
it now."
In the unlikely event that a hard restart doesn’t work, DoF9 prompts you to switch off your Mac using the rear power switch. If you need to do this, you definitely have some serious software problems.
DoF12 G # leave MacsBug
DoF12 is a shortcut to the Go command used to exit MacsBug. I chose F12 because this key is conveniently located to the left of the Powerkey used to invoke MacsBug on a PowerBook 5300 keyboard.
DoF15 G # leave MacsBug
DoF15 is a shortcut to the Go command used to exit MacsBug. I chose F15 because this key is conveniently located to the left of the Powerkey used to invoke MacsBug on an extended keyboard.
Questions?
If you’re confused or have any problems using the enclosed macros, feel free to send me e-mail at pooka1@bigfoot.com.
Documentation written using Tom Bender’s Tex-Edit Plus. http://members.aol.com/tombb/